/**
 * use of multiple JavaScript constructs/statements
 */

var x = a
var n = x * 2 + x * 2;
var n, m;
var s = "hello\tworld\n"
var arr = [1, 2, 3, 3.14];
var many = x = n = 2 * x

x += 2
n -= x * x;
m += x /= 2

function f1() {}

var f2 = function(p1) {
   var f = 2.334e+5
   var n = null;
   var o = { prop1: f, prop2: n != null ? n : f * f, param: p1 << 2 }
   var exp = ((h * h) + (h * h)) / (c * c);

   with (o) {
      exp -= n;
      n *= 2
   }

   if ( p1 > 10 ) o.propnew = p1 * 3;;
 
   f = (function innerf() {
      var mya = ~0;
   })();

   f2 = (function(a1, a2) {
      var a;
      
      if ( a1 > a2 ) {
         a = a1 * a2 + a1
      } else {
         a = a1 / a2
      }
   })(40, p1 * p1);

   if (/^\w{2} [^0-9]+ \d*$/gi.exec(p1)) {
      return true;
   }

   var v = 23.56/p1/f;

   return f;
}

f2(m + 3);

// test throw and try statements
function f(a) {
   if (!a)
      throw Error("invalid");
}

try {
   f(null);
}
catch(ex) {
   report();
}
finally {
   cleanUp()
}


for (var i = 0; i < arr.length; i += 1)
   f(i);

for (var i=0; i<10; i++) {
   callFun(i * i)
}

for (e = a.length; e >= 0; e--)
{
   if (a[e]) 
      doIt(a[e]);
}

// test

var arr = [{
      a: 123,
      "bcd": 3.1415,
      x: o.param
   }, {
      a: true,
      'qwert' : 0xfffe,
      f : function(arg) { return !!args; }
   }, {
      a : [1,2,3],
      f : f1(++a, n = 2),
      inst: new Widget,
      inc : n++,
      w : arr[1],
      w2 : arr["1"],
      w3 : obj['id'][a << 2]
   }
]

var y = x !== y || z && b;; 
var x_2 = a & x & v | z & y, other = qwertz ? r1 : b || c // test comment

x = 10
while (true) {
   print(x++)
}

do {
   y *= 3;
} while (x > 10 && y < 150);

function fun(arg1, arg2,arg3) {
   var all = []
   var fcall = f1()
   var a, b, c = arg1 += arg2;
   var _t = a & (b | c)
   var myStr = "arg1 id = " + arg1.id;
   var obj = { 
         str: myStr, 
         todo: typeof arg2 === "object",
         expr: a + c * b / arg3 >>> 1,
         funny : function(p1, p2, p3, p4, p5) {
            var v = (p1 > p2) ? true : p4 || p5;
            var str = "p3 = " + p3;
            var arr = [p1, p2, p3, p4, p5]
         },
         autoWidth: true,
         p: f1().prop[2]
   }

   all[0] = 1;
   a = 1;
   all[a++] = all[0] + 1
   all[a] = f1()
   all[1 + a] = f1(12.3, [1,2,3])[0];

   for (p in obj) {
      doIt(obj[p])
   }

   for (var p in obj) { that(obj, p); }

   /*
   for each(var val in obj) {
      whatever(val);
      if (val instanceof Widget) continue;
   }
   */

   function inner(p1) {
      var x = a || t || false;;
      {
         var xx=c & b || z && u
         while (true) print(p1);
      }
      return;
   }
   ;

   var result = inner(123);

   var o = {a: 1, b: 2, c: 3.14}
   var vv = a == x ? c : nma, me = this
   var arr = [1, 2, [1, 2, 3, a * b], {}, o.a, o.b, o.a.b.c[1]]

   var inner2 = function(p1, p2, p3) {
      var sum = p1 + p2 + p3;
      var formula = p1 * p2 + p3
   }

   var res = inner2({id: 123}, [a + b * c, (a || b) && c], true);
   var arr = [vv, inner2, inner2({}, []), this, a * b + c, 4 << 2, a & 0xff, arr[2][a]]
   var res2 = arr[2](12.5, [a,b,c], {}).prop.whatever;

   i = 0;
   while (arr.length < 100) {
      arr[i++] = i * i
      if ( i > 50 ) break;
   }

   for (var i; ; ) ; // forever and ever
}

function testeSwitch(val) {
   switch (typeof val) {
      case "string":
         dealString(val);
         break;
      case "number":
         doSomeMath(val);
         break;
      case 'boolean':
         doSomeLogic(val);
         break;
      default:
         keepBusy(val);
         return false;
   }

   return true
}

var widget = new Widget;
var widget = new Widget('myid', { autoHeight: true, items: [] })
var isWidget = typeof widget === whateverString;
var inst = widget instanceof Widget
var a = x % y
